package com.jufanshare.myblog.dao.email;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

/**
 * @功能：
 * @开发者： 大BUG
 * @编写时间： 2019/2/1 16:48
 */
@Component
public class EmailRepository {
    @Value("${spring.mail.username}")
    private String fromName;
    @Autowired
    private JavaMailSender mailSender;
    public void sendEmailCode(String email,String code){
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(fromName);
        message.setTo(email);
        message.setSubject("邮箱验证码-聚繁分享");
        message.setText("您好！您的验证码是：\r\n"+code);
        mailSender.send(message);
    }
}
